package com.nuc.bigdata;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;

/**
 * @author JackLuo
 * @date 2019/10/8
 */
@SpringBootApplication
@EnableDiscoveryClient
@RefreshScope
public class GatewayApplication {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
//                .route(r -> r.path("/manage/**").filters(f -> f.stripPrefix(1))
//                        .uri("lb://oa-management")
//                )
                .route(r -> r.path("/v1/**")
                        .uri("lb://oa-management")
                )
                .route(r -> r.path("/oa-picture/**").uri("lb://oa-picture"))
                .route(r -> r.path("/front/**").uri("lb://oa-front"))
                .route(r -> r.path("/oa-front/**").uri("lb://oa-front"))
                .route(r -> r.path("/oa-photos/**").uri("lb://oa-photos"))
                .build();
    }

    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }
}
